package com.example.expandablelistview.fragmentdialog;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.app.DialogFragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.example.expandablelistview.R;

public class PreCreateDialog extends Activity {
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.dialogex);
	}

	public void mOnClick(View v) {
		DialogFragment newFragment = new DialogFragmentEx();
		newFragment.show(getFragmentManager(), "Dialog");
	}

	class DialogFragmentEx extends DialogFragment {
		public Dialog onCreateDialog(Bundle savedInstanceState) {
			AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
			builder.setTitle("알립니다")
					.setMessage("DialogFragment 를 열었습니다")
					.setPositiveButton("확인",
							new DialogInterface.OnClickListener() {
								public void onClick(DialogInterface dialog,
										int id) {
									Toast.makeText(getActivity(), "확인 버튼 누름",
											Toast.LENGTH_LONG).show();
								}
							}).setNegativeButton("닫기", null);
			return builder.create();
		}
	}
}
